package com.study.service.PSIservice;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.study.model.jdao.PSIjdao.PurchaseOrderDao;
import com.study.model.pojo.PSIpojo.PurchaseOrder;
@Service
public class PurchaseOrderServices {
	@Autowired
	PurchaseOrderDao podao;
	
	/**
	 * 查询所有采购订单
	 * @return
	 */
	public List<PurchaseOrder> selectAll(){
		return (List<PurchaseOrder>) podao.findAll();
	}	
	
	public PurchaseOrder findByPurorderid(String purorderid){
		return podao.findByPurorderid(purorderid);		
	}	
	
	/**
	 * 新增
	 * @param po
	 * @return
	 */
	public String addOne(PurchaseOrder po) {
		podao.save(po);
		return po.getRemark();	
	}
	
	/**
	 * 修改订单审核状态为2已审核
	 * @param purorderid
	 */
	public void updateYesState(String purorderid){
		PurchaseOrder po = podao.findByPurorderid(purorderid);
		po.setPurstate(2);
		podao.save(po);
	}
	
	/**
	 * 修改订单审核状态为3已删除
	 * @param purorderid
	 */
	public void updateNoState(String purorderid){
		PurchaseOrder po = podao.findByPurorderid(purorderid);
		po.setPurstate(3);
		podao.save(po);
	}
	/**
	 * 修改
	 * @param po
	 */
	public void savePurchaseOrder(PurchaseOrder po) {
		podao.save(po);
	}
}